<template>
  <el-dialog
    title="修改隧道信息"
    :visible.sync="dialogEditorVisible"
    width="50%"
    :before-close="handleClose"
  >
    <el-form class="demo-form-inline" ref="form" :model="currentRow" label-width="100px">
      <el-row>
        <el-col :span="12">
          <el-form-item label="断面名称">
            <el-input v-model="currentRow.sectionName"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="施工状态">
            <el-radio v-model="currentRow.status" label="1">施工中</el-radio>
            <el-radio v-model="currentRow.status" label="2">已完成</el-radio>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="围岩级别">
            <el-select v-model="currentRow.wallgrade" placeholder="请选择围岩级别">
              <el-option label="Ⅱ" value="2"></el-option>
              <el-option label="Ⅲ" value="3"></el-option>
              <el-option label="Ⅳ" value="4"></el-option>
              <el-option label="Ⅴ" value="5"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogEditorVisible = false">取 消</el-button>
      <el-button type="primary" @click="create">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import api from "../../../api";
import qs from "qs";

export default {
  data() {
    return {
      dialogEditorVisible: false,
      eTypeList: [],
      tunnelList: [],
      fileList: [],
      currentRow: {},
    };
  },
  mounted() {
    this.$bus.$on("onShowSectionEditor", (row) => {
      this.dialogEditorVisible = true;
      this.currentRow = row.rowdata;
    });
    this.kaiwa();
  },
  methods: {
    kaiwa() {
      api
        .eTypeFindByAll()
        .then((res) => {
          if (res.data.code == 2001) {
            this.eTypeList = res.data.data;
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          done();
        })
        .catch((_) => {});
    },
    create() {
      api
        .tunnelSectionUpdate(qs.stringify(this.currentRow))
        .then((res) => {
          if (res.data.code == 2001) {
            this.$message({
              type: "success",
              message: "更新成功!",
            });
            this.dialogEditorVisible = false;
            this.$bus.$emit("onRefreshSection", this.scetion.wId);
          } else {
            this.$message({
              type: "fail",
              message: "更新失败!",
            });
            this.dialogVisible = false;
            this.$bus.$emit("onRefresh", true);
          }
        })
        .catch((err) => {});
    },
    onSubmit() {
      console.log("submit!");
    },
  },
};
</script>

<style scoped>
.avatar-uploader .el-upload {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
}

.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}

.avatar-uploader-icon {
  width: 50px !important;
  height: 50px !important;
  font-size: 28px;
  line-height: 50px !important;
  color: #8c939d;
  text-align: center;
}

.avatar {
  display: block;
  width: 50px !important;
  height: 50px !important;
}

.imgbeforepad {
  padding-top: 0px !important;
}

.avatar-uploader .el-icon-plus {
  margin: 15px !important;
}
</style>